<template>
  <div class="Artistalbum">
    <div class="main">
      <div class="imglist" v-for="(item,index) in hotAlbums" :key="item.id" :class="index%2==0?'b':''">
        <img :src="item.blurPicUrl" alt="">
        <span class="span1">{{item.name}}</span>
        <span class="span2">{{item.size}}首</span>
        <span class="span3" v-for="(item1,index1) in Timemerge" :key="index1" v-show="index==index1">发行时间:&nbsp;&nbsp;{{item1}}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'Artistalbum',
  data() {
    return {
      time: [],
      limit: 30,
      UTCFullYear: [],
      Month: [],
      UTCDate: [],
      Timemerge: []
    }
  },
  computed: {
    ...mapState({
      hotAlbums: state => state.Singger.hotAlbums
    })
  },
  mounted() {
    this.$store.dispatch('getGetthesingeralbum', { id: this.$route.query.id, limit: this.limit })
  },
  watch: {
    hotAlbums: {
      handler(v, o) {
        this.time = v.map(val => {
          return val.publishTime
        })
      }
    },
    time: {
      handler(v, o) {
        this.UTCFullYear = v.map(val => {
          let y = new Date(val)
          return y.getUTCFullYear()
        })
        this.Month = v.map(val => {
          let m = new Date(val)
          return m.getMonth() + 1
        })
        this.UTCDate = v.map(val => {
          let d = new Date(val)
          return d.getUTCDate() + 1
        })
      }
    },
    UTCDate: {
      handler(v, o) {
        for (let i = 0; i < v.length; i++) {
          this.Timemerge.push(this.UTCFullYear[i] + '-' + this.Month[i] + '-' + this.UTCDate[i])
        }
      }
    }
  }
}
</script>

<style lang="less" scoped>
.Artistalbum {
  .main {
    .b {
      background-color: rgb(245, 244, 243);
    }
    .imglist {
      display: flex;
      align-items: center;

      width: 1250px;
      padding: 10px;
      img {
        width: 60px;
        height: 60px;
        border-radius: 5px;
      }
      img:hover {
        cursor: pointer;
      }
      .span1 {
        font-size: 13.5px;
        margin-left: 10px;
        opacity: 0.7;
        width: 550px;
      }
      .span1:hover {
        cursor: pointer;
        opacity: 1;
      }
      .span2 {
        font-size: 12.5px;
        opacity: 0.6;
      }
      .span3 {
        font-size: 12px;
        opacity: 0.6;
        margin-left: 400px;
      }
    }
    .imglist:hover {
      background-color: rgb(236, 236, 234);
    }
  }
}
</style>